from etgui import *
import CmdNo,sys
#import ErrorDialog
#ErrorDialog.SetError("dialog")
def QuantifyStopFile():
		QuantifyStop('/tmp/sniff')
from PyDialog import PyDialog

class Runner:
	def __init__(self,module,method="Show"):
		self.module=module
		self.method=method
	def __call__(self):
		module=self.module
		method=self.method
		exec 'import %(module)s;reload(%(module)s);%(module)s.%(method)s()'%vars() in vars(),globals()

class TestDialog(PyDialog):
	def ShowUnderMouse(self):
		self.impl.ShowUnderMouse()
	def MakeContent(self):
		return VBox(
			align=eVObjHExpand|eVObjVCenter,
			items= (
				ActionButton("Python Input",action=Runner("PyInputDialog")),
				ActionButton("Welcome",action=Runner("WelcomeDialog")),
				ActionButton("Setup",action=Runner("SetupWizard","ShowModal")),
				ActionButton("ProjAtts",action=Runner("tests.ProjAtts")),
				ActionButton("ListEditors",action=Runner("tests.ListEditTest")),
				ActionButton("DictEditors",action=Runner("tests.DictEditTest")),
				ActionButton("ModelDictEditors",action=Runner("tests.ModelDictEditTest")),
				ActionButton("ModelDecorator",action=Runner("tests.ModelDecoratorTest")),
				ActionButton("Beginner Dialog",action=Runner("tests.BeginnerDialog")),
				ActionButton("Example Dialog 1",action=Runner("tests.ExampleDialog1")),
				ActionButton("Example Dialog 2",action=Runner("tests.ExampleDialog2")),
				ActionButton("Start Quantify",action=QuantifyStart),
				ActionButton("Stop Quantify",action=QuantifyStopFile),
				ActionButton(CmdNo.cIdOk,"!Exit!",action=sys.exit),
				ActionButton(CmdNo.cIdCancel,"Done",default=1),
			)
		)

def Show():
	global dialog
	dialog=MakeDialog(TestDialog())
	dialog.ShowUnderMouse()
	return
if __name__=='__main__':
	Show()
